package com.itheima.health.service.impl;

import com.itheima.health.dao.OrderDao;
import com.itheima.health.dto.OrderSubmitParam;
import com.itheima.health.pojo.Order;
import com.itheima.health.service.OrderService;;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServicelmpl implements OrderService {

    @Autowired
    private OrderDao orderDao;

    @Override
    public Order add(OrderSubmitParam orderSubmitParam) {

        //创建一个Order对象
        Order order = new Order();
        //在orderSubmitParam获取 预约日期 套餐id 传进order中
        order.setOrderDate(orderSubmitParam.getOrderDate());
        order.setSetmealId(orderSubmitParam.getSetMealId());

        //设定成员id 订单类型
        order.setMemberId(100);
        order.setOrderType(Order.ORDERTYPE_WEIXIN);

        orderDao.insert(order);

        return order;
    }

    /**
     * 订单详情
     * @param id
     * @return
     */
    @Override
    public Order selectById(Integer id) {
        Order order = orderDao.selectById(id);
        return order;
    }
}
